#!/bin/sh
#################################
# use for fun. created by agate #
# contact: agate.hao@gmail.com  #
# website: http://agatezone.cn  #
#################################

PRG="$0"

while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> \(.*\)$'`
    if expr "$link" : '/.*' > /dev/null; then
        PRG="$link"
    else
        PRG=`dirname "$PRG"`"/$link"
    fi
done

DIRNAME=`dirname $PRG`

TOMCAT_HOME=`cd $DIRNAME; pwd`

f1=$TOMCAT_HOME/bin/startup.sh
f2=$TOMCAT_HOME/bin/shutdown.sh

mkdir tomcat-temp
for f in $f1 $f2; do
	ln -s $f tomcat-temp
done
sudo mv ./tomcat-temp/startup.sh /usr/bin/tomcat-startup
sudo mv ./tomcat-temp/shutdown.sh /usr/bin/tomcat-shutdown
rm tomcat-temp -r
